﻿@using CNKI.TPI.Web.Search.Model;
@using CNKI.TPI.Web.Base;
<script>
    //组全选
    function dblistcheckall(e) {
        if ($(e).attr("checked") == "checked") {
            $(".checkboxdb input[type='checkbox']").each(function () {
                $(this).attr("checked", "checked");
            })
        }
        else {
            $(".checkboxdb input[type='checkbox']").each(function () {
                $(this).removeAttr("checked", "checked");
            })
        }
    }
    $(".checkboxdb input[type='checkbox']").click(function () {
        //循环判断列表中的checkbox，如果全部选中则全选框呈勾选状态
        var m = 0;
        if ($(this).attr("checked") != "checked") {
            $("input.dbcheckall").removeAttr("checked", "checked");
        }
        else {
            $(".checkboxdb input[type='checkbox']").each(function () {
                if ($(this).attr("checked") != "checked") {
                    m = 1;
                }
            })
            if (m == 1) {
                $("input.dbcheckall").removeAttr("checked", "checked");
            }
            else {
                $("input.dbcheckall").attr("checked", "checked");
            }
        }

    })
</script>
<table width="100%" cellspacing="0" cellpadding="0" border="0" class="table table-grey">
    <thead>
        <tr class="thead">
            <th class="tdnum tdnum1">
                <input type="checkbox" class="dbcheckall" onclick="dblistcheckall(this)" value="" name="">序号</th>
            <th>数据库名称</th>
            <th>操作权限</th>
            <th>每日下载量</th>
            <th>最大下载量</th>
            <th>字段权限</th>
            <th>导航权限</th>
            <th>操作</th>
        </tr>
    </thead>
    <tbody>


        @{if (ViewBag.SearchResult != null)
          {
              int sortno = ViewBag.PageSize * (ViewBag.PageNow - 1) + 1;
              foreach (System.Data.DataRow dr in ViewBag.SearchResult.Rows)
              {
                  string str = "even";
                  if (sortno % 2 == 0)
                  {
                      str = "odd";
                  }
            <tr class='@str'>
                <td class="checkboxdb">
                    <input name="" type="checkbox" value="@dr["ID"]" />@sortno</td>
                @foreach (System.Data.DataColumn column in ViewBag.SearchResult.Columns)
                {
                    if (column.ColumnName != "ID")
                    {
                      
                    <td>
                        <a title="@dr[column.ColumnName]" style="text-decoration:none;cursor:default;">
                            @Html.Raw(ColumnAliasHelper.SubContent(dr[column.ColumnName].ToString(), 10))
                        </a>
                    </td>    
                    }
                }
                <td class="tc">
                    <a onclick="modifydbauth('@dr["ID"]')" href="javascript:void(0)">编辑</a>
                </td>
            </tr>
                sortno = sortno + 1;
              }

          }
        }

    </tbody>
</table>

@*//分页*@
<div class="pagenav pagenav-02">
    @*上一页*@
    @if (ViewBag.TotalPage > 0)
    {
        if (ViewBag.PageNow != 1)
        {
            int thispage = ViewBag.PageNow - 1;
        <a href="javascript:void(0);" class="page-prev" onclick="searchPageNew('@thispage')" >上一页</a>
        }
        else
        {
        <a href="javascript:return false;"  onclick="return false" class="page-prev disable">上一页</a>
        }
@*循环初始化页码*@
        foreach (string numpage in ViewBag.PageList)
        {
            if (numpage != "0")
            {
                int m = int.Parse(numpage);
                if (m == ViewBag.PageNow)
                {
        <a href="javascript:void(0);" class="active" onclick="searchPageNew('@numpage')">@numpage</a>
                    
                }
                else
                {
        <a href="javascript:void(0);" onclick="searchPageNew('@numpage')">@numpage</a>
                }

            }
            else
            {
        <i class="iconfont icon-dian2"></i>
            }

        }
@*下一页*@
        if (ViewBag.PageNow != ViewBag.TotalPage)
        {
            int nextpage = ViewBag.PageNow + 1;
        <a href="javascript:void(0);" class="page-next" onclick="searchPageNew('@nextpage')" >下一页</a>
        }
        else
        {
        <a href="javascript:return false;"  onclick="return false" class="page-prev disable">下一页</a>
        }
    }
   
        @if (ViewBag.ResultCount == 0)
        {
        <label>暂无数据！</label>
        
        }
        else
        {
          
        <label>共 </label>
        <label>@ViewBag.ResultCount </label>
        <label>条数据 </label>
        }
  
</div>
